package com.xuxin.baby.presenter;

import com.xuxin.baby.bean.BaseBean;
import com.xuxin.baby.bean.CategoryBean;
import com.xuxin.baby.bean.ReaderVideoBean;
import com.xuxin.baby.contract.CategoryContract;
import com.xuxin.baby.model.CategoryModel;

/**
 * Created by xu_xin
 * Created on 2020/10/22 0022
 * 早教分类/保健分类
 */
public class CategoryPresenter implements CategoryContract.Presenter {
    private final CategoryModel model;
    private final CategoryContract.View view;

    public CategoryPresenter(CategoryContract.View view) {
        this.view = view;
        model = new CategoryModel();
    }

    @Override
    public void getCategory(String tenantId, String token, String layout, String parentId) {
        if (null != model) {
            model.getCategory(this, tenantId, token, layout, parentId);
        }
    }

    @Override
    public void onSuccess(CategoryBean categoryBean) {
        if (null != view) {
            view.onSuccess(categoryBean);
        }
    }

    /**
     * 以下内容复用(用于请求完成后的操作)
     */
    @Override
    public void onError(BaseBean baseBean) {
        if (null != view) {
            view.onError(baseBean);
        }
    }

    @Override
    public void onComplete() {
        if (null != view) {
            view.onComplete();
        }
    }
}